﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace SHW_UP.UI
{
    public partial class frmSelectPort : Form
    {
        public frmSelectPort()
        {
            InitializeComponent();
        }

        public void GetComList()
        {
            RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
            if (keyCom != null)
            {
                string[] sSubKeys = keyCom.GetValueNames();
                this.serialnoPortListCombox.Items.Clear();
                foreach (string sName in sSubKeys)
                {
                    string sValue = (string)keyCom.GetValue(sName);
                    this.serialnoPortListCombox.Items.Add(sValue);
                }
            }
        }

        private void frmSelectPort_Load(object sender, EventArgs e)
        {
            GetComList();
        }

        private void serialnoPortListCombox_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void selectPortCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void selectPortSubmit_Click(object sender, EventArgs e)
        {
            frmMain.comPort = this.serialnoPortListCombox.Text;
            this.Close();
        }
    }
}
